#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     struct ListNode *next;
 * };
 */
struct ListNode* getIntersectionNode(struct ListNode* headA, struct ListNode* headB)
{
    int lena = 0, lenb = 0, i;
    struct ListNode* p = headA, * q = headB;
    while (p)
    {
        lena++;
        p = p->next;
    }
    while (q)
    {
        lenb++;
        q = q->next;
    }
    p = headA, q = headB;
    if (lena < lenb)
    {
        for (i = 0; i < lenb - lena; i++)
            q = q->next;
        while (p && q)
        {
            if (p == q)
                return p;
            p = p->next;
            q = q->next;
        }
    }
    else
    {
        if (p == q)
            return p;
        for (i = 0; i < lena - lenb; i++)
            p = p->next;
        while (p && q)
        {
            if (p == q)
                return p;
            p = p->next;
            q = q->next;
        }
    }
    return NULL;
}
int main()
{
	printf("hh");
	return 0;
}